using Nop.Plugin.DiscountRules.Customers.Domain;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nop.Plugin.DiscountRules.Customers.Data
{
	public class DiscountCustomerMap : EntityTypeConfiguration<RequirementCustomer>
	{
		public DiscountCustomerMap()
		{
			this.ToTable("Discount_Plugin_AssignToCustomers");
			this.Property(x => x.CustomerId).IsRequired();			
			this.Property(x => x.RequirementId).IsRequired();
			this.Property(x => x.CreatedOnUtc).IsRequired();
			this.HasKey(x => new { RequirementId = x.RequirementId, CustomerId = x.CustomerId });
			this.Ignore(x => x.Id);

			this.HasRequired(x => x.Customer).WithMany().HasForeignKey(x => x.CustomerId);			
			this.HasRequired(x => x.Requirement).WithMany().HasForeignKey(x => x.RequirementId);
		}
	}
}
